require("luaext")
require "skynet.manager"
local skynet = require "skynet"

local MessageDispatch = require "MessageDispatch"
local MessageHandler = require "manager.MessageHandler"
local ClusterManager = require "ClusterManager"

global = {}

local function init()

	local message_dispatch = MessageDispatch.new()	

	local message_handler = MessageHandler.new(message_dispatch)
	local cluster_manager = ClusterManager.new()

	global.message_dispatch = message_dispatch
	global.message_handler = message_handler
	global.cluster_manager = cluster_manager

	--lua消息的派发
	skynet.dispatch("lua", message_dispatch:dispatch())	
	--开启集群节点
	global.cluster_manager:open()		
end

---------------------------------------------------------
-- skynet
---------------------------------------------------------

skynet.start(function()

	init()

	skynet.register('.manager')
end)

